<script setup lang="ts">
import { shelfRequestParams, RequestParams } from "@/api/bookShelf/type";
import {
  BookshelfList,
  addBookshelf,
  delBookshelf,
  FormBookshelf,
  updateBookshelf,
  StandardOptions,
  syncBook,
  batchAddBookshelf,
} from "@/api/bookShelf/index";
import { BookshelfOptions } from "@/api/inventory";
import { LibraryOptions } from "@/api/library/index";
import { ElMessage, ElMessageBox } from "element-plus";
import { computed, onMounted, reactive, ref, watch } from "vue";
import useUserStore from "@/store/modules/user";
import { optionsList } from "@/api/Marker/index";
let useStore = useUserStore();
// ================================================================================
// ref
const ruleFormRef = ref(); //弹框表单
const ids = ref([] as number[]); //表格全选
const total = ref();
const loading = ref(false);
const dialogVisible = ref(false);
const title = ref("新增");
let LibOptions = ref([] as any);
const ruleForm = ref({} as any);
let queryParams = reactive({
  pageNum: 1,
  pageSize: 10,
} as RequestParams);
const tableList = ref([{}] as shelfRequestParams[]);
// 自定义验证规则：验证数字格式
// const validateLength = (rule, value, callback) => {
//   if (value === "") {
//     callback(new Error("书架长度不能为空"));
//   } else if (!/^\d+(\.\d+)?$/.test(value)) {
//     callback(new Error("请输入有效的数字（可以是小数）"));
//   } else {
//     callback();
//   }
// };
// const validateWidth = (rule, value, callback) => {
//   if (value === "") {
//     callback(new Error("书架宽度不能为空"));
//   } else if (!/^\d+(\.\d+)?$/.test(value)) {
//     callback(new Error("请输入有效的数字（可以是小数）"));
//   } else {
//     callback();
//   }
// };
const validateHeight = (rule, value, callback) => {
  if (value === "") {
    callback(new Error("书架高度不能为空"));
  } else if (!/^\d+(\.\d+)?$/.test(value)) {
    callback(new Error("请输入有效的数字（可以是小数）"));
  } else {
    callback();
  }
};
const shelfTotalLayerHeight = (rule, value, callback) => {
  if (value === "") {
    callback(new Error("书架总层高不能为空"));
  } else if (!/^\d+(\.\d+)?$/.test(value)) {
    callback(new Error("请输入有效的数字（可以是小数）"));
  } else {
    callback();
  }
};

const shelfTotalLayer = (rule, value, callback) => {
  if (value === "") {
    callback(new Error("书架总层数不能为空"));
  } else if (!/^\d+(\.\d+)?$/.test(value)) {
    callback(new Error("请输入有效的数字（可以是小数）"));
  } else {
    callback();
  }
};
const shelfLayerHeight = (rule, value, callback) => {
  if (value === "") {
    callback(new Error("书架层高不能为空"));
  } else if (!/^\d+(\.\d+)?$/.test(value)) {
    callback(new Error("请输入有效的数字（可以是小数）"));
  } else {
    callback();
  }
};
const rules = reactive({
  robotId: [{ required: true, message: "请选择机器人", trigger: "change" }],
  direction: [{ required: true, message: "请选择方向", trigger: "change" }],
  // rfidNearShelfList: [
  //   { required: true, message: "请选择rfid相邻书架", trigger: "change" },
  // ],
  // ocrNearShelfList: [
  //   { required: true, message: "请选择ocr相邻书架", trigger: "change" },
  // ],
  libraryId: [
    { required: true, message: "请选择图书馆", trigger: "change" },
    // { min: 1, max: 5, message: "请输入1到5位", trigger: "blur" },
  ],
  shelfName: [
    { required: true, message: "书架名称不能为空", trigger: "change" },
    { min: 1, max: 30, message: "书架名称过长", trigger: "change" },
  ],
  standardId: [
    { required: true, message: "请选择书架规格", trigger: "change" },
  ],
  // shelfLength: [

  //   { required: true, message: "书架长度不能为空", trigger: "blur" },
  //   { validator: validateLength, trigger: "blur" },
  // ],
  // shelfWidth: [
  //   { required: true, message: "书架宽度不能为空", trigger: "blur" },
  //   { validator: validateWidth, trigger: "blur" },
  // ],
  shelfHeight: [
    { required: true, message: "书架高度不能为空", trigger: "change" },
    { validator: validateHeight, trigger: "change" },
  ],
  twoSides: [
    {
      required: true,
      message: "请选择书架类型",
      trigger: "change",
    },
  ],
  shelfTotalLayerHeight: [
    { required: true, message: "书架总层高不能为空", trigger: "change" },
    { validator: shelfTotalLayerHeight, trigger: "change" },
  ],
  shelfTotalLayer: [
    { required: true, message: "书架总层高不能为空", trigger: "change" },
    { validator: shelfTotalLayer, trigger: "change" },
  ],
  firstPosToShelf: [
    { required: true, message: "起始点到书架距离不能为空", trigger: "change" },
  ],
  shelfLayerHeight: [
    { required: true, message: "书架层高不能为空", trigger: "change" },
    { validator: shelfLayerHeight, trigger: "change" },
    // { min: 1, max: 5, message: "请输入1到5位", trigger: "blur" },
  ],
  shelfXPos: [
    { required: true, message: "书架X端坐标不能为空", trigger: "change" },
    // { min: 1, max: 5, message: "请输入1到5位", trigger: "blur" },
  ],
  shelfYPos: [
    { required: true, message: "书架Y端坐标不能为空", trigger: "change" },
    // { min: 1, max: 5, message: "请输入1到5位", trigger: "blur" },
  ],
  returnBookPos: [
    { required: true, message: "还书坐标不能为空", trigger: "change" },
    // { min: 1, max: 5, message: "请输入1到5位", trigger: "blur" },
  ],
});
// 挂载
onMounted(() => {
  handleQuery();
});
// ================================================================================

/**
 * 查询
 */
const handleQuery = async () => {
  try {
    loading.value = true;
    const res = await BookshelfList(queryParams);
    // console.log(res, "res");

    tableList.value = res.data.records;

    total.value = res.data.total;
    loading.value = false;
  } catch (error) {
    // console.error(error);
    loading.value = false; // 将 loading 的值设置为 false，以便停止加载动画
  }
};
/**
 * 重置
 */
const resetQuery = () => {
  queryParams.shelfName = "";
  handleQuery();
};
/**
 * 行checkbox change事件
 */
function handleSelectionChange(selection: any) {
  ids.value = selection.map((item: any) => item.id);
}
const robotOptions = ref([] as any); //批量新增
/**
 * 打开弹框
 */
const StandardOpt = ref([] as any);
const bookshelfref = ref();
const Bookshelf = ref([] as any);
const ocrBookshelf = ref([] as any);
// const ocrNearShelfListref = ref();
const openDialog = async (id?: number) => {
  // 先重置表单
  ruleForm.value = {
    // 初始化所有字段
    libraryId: null,
    twoSides: null,
    standardId: null,
    shelfName: "",
    shelfXPos: "",
    shelfYPos: "",
    returnBookPos: "",
    // rfidNearShelfList: [],
    // ocrNearShelfList: []
  };
  Bookshelf.value = [];
  // ruleForm.value.rfidNearShelfList = [];
  // ruleForm.value.ocrNearShelfList = [];
  const res = await LibraryOptions(useStore.encryptedData);
  LibOptions.value = res.data;

  const ress = await StandardOptions(useStore.encryptedData);
  StandardOpt.value = ress.data;
  console.log(StandardOpt.value, "StandardOpt.value");

  dialogVisible.value = true;
  if (id) {
    const res = await FormBookshelf(id as any);
    ruleForm.value = res.data;
    const ress = await BookshelfOptions(res.data.libraryId as any);
    Bookshelf.value = ress.data;
    ocrBookshelf.value = ress.data;
    // console.log(res, "addFormUser");
    title.value = "修改书架";
  } else {
    title.value = "新增书架";
  }
};
const batchAddruleForm = ref({} as any);
const dialogbatchAdd = ref(false);
const batchAdd = async () => {
  // 先重置表单
  batchAddruleForm.value = {};
  dialogbatchAdd.value = true;
  const re = await LibraryOptions(useStore.encryptedData);
  LibOptions.value = re.data;

  title.value = "批量新增";
  const res = await optionsList(useStore.encryptedData);
  robotOptions.value = res.data;
  const ress = await StandardOptions(useStore.encryptedData);
  StandardOpt.value = ress.data;
  console.log(StandardOpt.value, "StandardOpt.value");
};
const change = async (e: any) => {
  Bookshelf.value = [];
  ruleForm.value.rfidNearShelfList = [];
  const ress = await BookshelfOptions(e);
  Bookshelf.value = ress.data;
  ocrBookshelf.value = ress.data;
  bookshelfref.value.clearValidate();
  // ocrNearShelfref.value.clearValidate();
  // console.log(ress.data, "Bookshelf");
};

/**
 * 关闭弹框
 */
const close = () => {
  dialogVisible.value = false;
  dialogbatchAdd.value = false;
  ruleFormRef.value.resetFields();
  // 完全重置表单数据
  ruleForm.value = {
    // 初始化所有字段
    libraryId: null,
    twoSides: null,
    standardId: null,
    shelfName: "",
    shelfXPos: "",
    shelfYPos: "",
    returnBookPos: "",
    // rfidNearShelfList: [],
    // ocrNearShelfList: []
  };
  batchAddruleForm.value = {} as any;
};
/**
 * 处理表单提交事件
 */
const submit = async () => {
  ruleFormRef.value.validate((valid: any) => {
    if (valid) {
      const userId = ruleForm.value.id;
      loading.value = true;
      if (userId) {
        // console.log(ruleForm.value, "编辑");
        updateBookshelf(ruleForm.value)
          .then((res) => {
            if (res.code == 200) {
              ElMessage.success("书架修改成功");
              close();
              handleQuery();
            } else {
              ElMessage.error(res.msg);
              close();
              handleQuery();
              loading.value = false;
            }
          })
          .finally(() => (loading.value = false));
      } else {
        //  console.log("新增");
        ruleForm.value.libraryId = useStore.user.libraryId;
        addBookshelf(ruleForm.value)
          .then((res) => {
            if (res.code == 200) {
              ElMessage.success("书架新增成功");
              close();
              handleQuery();
            } else {
              ElMessage.error(res.msg);
              close();
              handleQuery();
              loading.value = false;
            }
          })
          .finally(() => (loading.value = false));
      }
    }
  });
};

const batchAddsubmit = async () => {
  ruleFormRef.value.validate((valid: any) => {
    if (valid) {
      loading.value = true;

      batchAddBookshelf(batchAddruleForm.value)
        .then((res) => {
          if (res.code == 200) {
            ElMessage.success("批量新增成功");
            close();
            handleQuery();
          } else {
            ElMessage.error(res.msg);
            close();
            handleQuery();
            loading.value = false;
          }
        })
        .finally(() => (loading.value = false));
    }
  });
};
/**
 * 删除
 */
const dell = (id: any) => {
  const userIds = [id || ids.value].join(",");
  if (!userIds) {
    ElMessage.warning("请勾选删除项");
    return;
  }
  ElMessageBox.confirm("确认删除吗?", "警告", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  }).then(function () {
    // console.log(Number(userIds), userIds);
    delBookshelf(id).then((res) => {
      if (res.code == 200) {
        ElMessage.success("删除成功");
        handleQuery();
      } else {
        ElMessage.error(res.msg);
      }
    });
  });
};
/**
 * 枚举
 */
const SidesStatus = (status: any) => {
  const STATUSES = [
    { id: 0, name: "单面书架" },
    { id: 1, name: "双面书架" },
  ];
  const matched = STATUSES.find((item) => item.id === status);
  return matched ? matched.name : "";
};
const handleSizeChange = (val: number) => {
  queryParams.pageSize = val;
  queryParams.pageNum = 1;

  handleQuery();
};
const handleCurrentChange = (val: number) => {
  queryParams.pageNum = val;
  handleQuery();
  window.scrollTo({ top: 0, behavior: "smooth" }); // 立即回到顶部，并使用平滑滚动效果
};
const twoSidesOptions = [
  { label: "单面书架", value: 0 },
  { label: "双面书架", value: 1 },
];
const indexMethod = (index: any) => {
  // 1、index:代表当前行数据的下标
  // 2、下标+1:  分页不要纠结：这块不是业务，完全是数学问题！
  return index + 1 + (queryParams.pageNum - 1) * queryParams.pageSize;
};
// 计算属性，返回已排序的 Bookshelf 数据源
const sortedBookshelf = computed(() => {
  return Bookshelf.value.slice().sort((a, b) => {
    // 根据 label 的字符串大小比较
    return a.label.localeCompare(b.label);
  });
});
const ocrBookshelfList = computed(() => {
  return ocrBookshelf.value.slice().sort((a, b) => {
    // 根据 label 的字符串大小比较
    return a.label.localeCompare(b.label);
  });
});

// 监听 formData.rfidNearShelfList 的变化，对其进行排序
watch(
  () => ruleForm.value.rfidNearShelfList,
  (newValue) => {
    if (newValue && Array.isArray(newValue)) {
      //  添加空值检查
      newValue.sort((a, b) => {
        const labelA =
          Bookshelf.value.find((item) => item.value === a)?.label || "";
        const labelB =
          Bookshelf.value.find((item) => item.value === b)?.label || "";
        return labelA.localeCompare(labelB);
      });
    }
  }
);
// 监听 formData.ocrNearShelfList 的变化，对其进行排序
// watch(
//   () => ruleForm.value.ocrNearShelfList,
//   (newValue) => {
//     if (newValue && Array.isArray(newValue)) {
//       newValue.sort((a, b) => {
//         const labelA =
//           ocrBookshelf.value.find((item) => item.value === a)?.label || "";
//         const labelB =
//           ocrBookshelf.value.find((item) => item.value === b)?.label || "";
//         return labelA.localeCompare(labelB);
//       });
//     }
//   }
// );
const Synchronize = async () => {
  try {
    await ElMessageBox.confirm("确认要同步书架吗?", "警告", {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning",
    });

    ElMessage.info("书架同步中，请稍候...");
    await syncBook(useStore.encryptedData);
    //ElMessage.success("数据同步成功");
  } catch {
    //ElMessage.error("数据同步失败，请重试");
  }
};
</script>

<template>
  <div class="app-container">
    <el-dialog
      v-model="dialogVisible"
      :title="title"
      width="550px"
      append-to-body
      @close="close"
    >
      <el-form
        ref="ruleFormRef"
        :model="ruleForm"
        :rules="rules"
        label-width="110px"
        status-icon
      >
        <el-form-item label="图书馆" prop="libraryId">
          <el-select
            style="width: 350px"
            v-model="ruleForm.libraryId"
            placeholder="请选择图书馆"
            @change="change"
          >
            <el-option
              v-for="item in LibOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>

        <el-form-item label="书架类型" prop="twoSides">
          <el-select
            style="width: 350px"
            v-model="ruleForm.twoSides"
            placeholder="请选择书架类型"
          >
            <el-option
              v-for="(status, index) in twoSidesOptions"
              :key="index"
              :label="status.label"
              :value="status.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="书架规格"
          prop="standardId"
          ref="bookshelfStandardref"
        >
          <el-select
            style="width: 350px"
            v-model="ruleForm.standardId"
            placeholder="请选择书架规格"
          >
            <el-option
              v-for="item in StandardOpt"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="书架名称" prop="shelfName">
          <el-input
            style="width: 350px"
            v-model="ruleForm.shelfName"
            placeholder="请输入书架名称"
          />
        </el-form-item>

        <!-- <el-form-item label="书架长度" prop="shelfLength">
          <el-input
            style="width: 350px"
            v-model="ruleForm.shelfLength"
            placeholder="请输入书架长度"
          />
        </el-form-item>
        <el-form-item label="书架宽度" prop="shelfWidth">
          <el-input
            style="width: 350px"
            v-model="ruleForm.shelfWidth"
            placeholder="请输入书架宽度"
          />
        </el-form-item>
        <el-form-item label="书架高度" prop="shelfHeight">
          <el-input
            style="width: 350px"
            v-model="ruleForm.shelfHeight"
            placeholder="请输入书架高度"
          />
        </el-form-item>
        <el-form-item label="书架层高" prop="shelfLayerHeight">
          <el-input
            style="width: 350px"
            v-model="ruleForm.shelfLayerHeight"
            placeholder="请输入书架层高"
          />
        </el-form-item>
        <el-form-item label="书架总层高" prop="shelfTotalLayerHeight">
          <el-input
            style="width: 350px"
            v-model="ruleForm.shelfTotalLayerHeight"
            placeholder="请输入书架总层高"
          />
        </el-form-item>
        <el-form-item label="书架总层数" prop="shelfTotalLayer">
          <el-input
            style="width: 350px"
            v-model="ruleForm.shelfTotalLayer"
            placeholder="请输入书架总层数"
          />
        </el-form-item>
        <el-form-item label="第一层距地高" prop="shelfFirstLayerHeight">
          <el-input
            style="width: 350px"
            v-model="ruleForm.shelfFirstLayerHeight"
            placeholder="请输入书架第一层距地高"
          />
        </el-form-item> -->
        <el-form-item label="书架起始坐标" prop="shelfXPos">
          <el-input
            style="width: 350px"
            v-model="ruleForm.shelfXPos"
            placeholder="请输入书架起始坐标"
          />
        </el-form-item>
        <el-form-item label="书架终止坐标" prop="shelfYPos">
          <el-input
            style="width: 350px"
            v-model="ruleForm.shelfYPos"
            placeholder="请输入书架终止坐标"
          />
        </el-form-item>
        <el-form-item label="还书坐标" prop="returnBookPos">
          <el-input
            style="width: 350px"
            v-model="ruleForm.returnBookPos"
            placeholder="请输入还书坐标"
          />
        </el-form-item>
        <!-- <el-form-item
          label="rfid相邻书架"
          prop="rfidNearShelfList"
          ref="bookshelfref"
        >
          <el-select
            style="width: 350px"
            multiple
            v-model="ruleForm.rfidNearShelfList"
            placeholder="请选择rfid相邻书架"
          >
            <el-option
              v-for="item in sortedBookshelf"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          label="ocr相邻书架"
          prop="ocrNearShelfList"
          ref="ocrNearShelfListref"
        >
          <el-select
            style="width: 350px"
            multiple
            v-model="ruleForm.ocrNearShelfList"
            placeholder="请选择ocr相邻书架"
          >
            <el-option
              v-for="item in ocrBookshelfList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item> -->
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submit">确 定</el-button>
          <el-button @click="close">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <el-dialog
      v-model="dialogbatchAdd"
      :title="title"
      width="550px"
      append-to-body
      @close="close"
    >
      <el-form
        ref="ruleFormRef"
        :model="batchAddruleForm"
        :rules="rules"
        label-width="135px"
        status-icon
      >
        <el-form-item label="图书馆" prop="libraryId">
          <el-select
            style="width: 350px"
            v-model="batchAddruleForm.libraryId"
            placeholder="请选择图书馆"
            @change="change"
          >
            <el-option
              v-for="item in LibOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>

        <el-form-item label="机器人" prop="robotId">
          <el-select
            style="width: 350px"
            v-model="batchAddruleForm.robotId"
            placeholder="请选择机器人"
          >
            <el-option
              v-for="item in robotOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="方向" prop="direction">
          <el-select
            style="width: 350px"
            v-model="batchAddruleForm.direction"
            placeholder="请选择方向"
          >
            <el-option label="正向" :value="1" />
            <el-option label="反向" :value="0" />
          </el-select>
        </el-form-item>
        <el-form-item
          label="书架规格"
          prop="standardId"
          ref="bookshelfStandardref"
        >
          <el-select
            style="width: 350px"
            v-model="batchAddruleForm.standardId"
            placeholder="请选择书架规格"
          >
            <el-option
              v-for="item in StandardOpt"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="书架名称" prop="shelfName">
          <el-input
            style="width: 350px"
            v-model="batchAddruleForm.shelfName"
            placeholder="请输入书架名称"
          />
        </el-form-item>

        <el-form-item label="还书坐标" prop="returnBookPos">
          <el-input
            style="width: 350px"
            v-model="batchAddruleForm.returnBookPos"
            placeholder="请输入还书坐标"
          />
        </el-form-item>
        <el-form-item label="书架X端坐标" prop="shelfXPos">
          <el-input
            style="width: 350px"
            v-model="batchAddruleForm.shelfXPos"
            placeholder="请输入书架X端坐标"
          />
        </el-form-item>
        <el-form-item label="书架Y端坐标" prop="shelfYPos">
          <el-input
            style="width: 350px"
            v-model="batchAddruleForm.shelfYPos"
            placeholder="请输入书架Y端坐标"
          />
        </el-form-item>
        <el-form-item label="起始点到书架距离" prop="firstPosToShelf">
          <el-input
            style="width: 350px"
            v-model="batchAddruleForm.firstPosToShelf"
            placeholder="请输入起始点到书架距离"
          />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="batchAddsubmit">确 定</el-button>
          <el-button @click="close">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <div class="search">
      <el-form ref="queryFormRef" :model="queryParams" :inline="true">
        <el-form-item label="书架名称" prop="name">
          <el-input
            v-model="queryParams.shelfName"
            placeholder="请输入书架名称"
            clearable
            @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleQuery" icon="Search"
            >搜索</el-button
          >
          <el-button @click="resetQuery" icon="Refresh">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-card>
      <template #header>
        <el-button icon="Plus" type="success" @click="openDialog()"
          >新增</el-button
        >
        <el-button icon="Plus" type="success" @click="batchAdd()"
          >批量新增</el-button
        >
        <el-button type="warning" style="margin-left: 10px" @click="Synchronize"
          >同步书架</el-button
        >
        <!-- <el-button type="danger" :disabled="ids.length === 0" icon="Delete"
          >删除</el-button
        > -->
      </template>
      <el-table
        v-loading="loading"
        highlight-current-row
        :data="tableList"
        :border="true"
        @selection-change="handleSelectionChange"
      >
        <!--  <el-table-column type="selection" width="55" align="center" /> > -->
        <el-table-column
          type="index"
          width="80"
          label="序号"
          :align="'center'"
          :index="indexMethod"
        />
        <el-table-column label="书架名称" prop="shelfName" align="center" />
        <!-- <el-table-column label="书架长度" prop="shelfLength" align="center" />
        <el-table-column label="书架宽度" prop="shelfWidth" align="center" />
        <el-table-column label="书架高度" prop="shelfHeight" align="center" />
        <el-table-column
          label="书架层高"
          prop="shelfLayerHeight"
          align="center"
        />
        <el-table-column
          label="书架总层高"
          prop="shelfTotalLayerHeight"
          align="center"
        />
        <el-table-column
          label="书架第一层距地高"
          prop="shelfFirstLayerHeight"
          align="center"
        />
        <el-table-column label="书架起始坐标" prop="shelfXPos" align="center" />
        <el-table-column label="书架终止坐标" prop="shelfYPos" align="center" /> -->
        <el-table-column label="书架类型" prop="twoSides" :align="'center'">
          <template #default="{ row }">
            {{ SidesStatus(row.twoSides) }}
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" align="center" width="220">
          <template #default="{ row }">
            <el-button
              type="primary"
              link
              size="small"
              @click="openDialog(row.id)"
              icon="Edit"
              >编辑</el-button
            >
            <el-button
              type="primary"
              link
              size="small"
              @click="dell(row.id)"
              icon="Delete"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        style="margin-top: 15px"
        v-model:current-page="queryParams.pageNum"
        v-model:page-size="queryParams.pageSize"
        :page-sizes="[10, 20, 30, 50, 100]"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-card>
  </div>
</template>

<style lang="scss" scoped></style>
